/*
@title: dicee_dare
@description: This is the game of Random dice rolling where you can carry Sprig as a dice in your pocket and Play Game of  Dares. In this game you have to prepare a bowl of Dares and write numbers on the chits , now you can use you Sprig and roll the dice to give each other the dares and have fun.
@author: Harsh Kumar
@tags: []
@addedOn: 2024-01-15
*/
const player = "p";
const d1 = "H";
const d2 = "T";
const d3 = "C";
const d4 = "P";
const d5 = "L";
const d6 = "h";
const s = "E";
let gameStarted = false;


setLegend(
  [player, bitmap`
................
..000000000000..
.02222222222220.
.02233333332220.
.02232222233220.
.02232222223220.
.02233222223220.
.02222222223220.
.02222233333220.
.02222232222220.
.02222222222220.
.02222232222220.
.02222222222220.
..000000000000..
................
................`],
  [d1, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02222233222220.
.02222233222220.
.02222233222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [d2, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02233222233220.
.02233222233220.
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [d3, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02332233223320.
.02332233223320.
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [d4, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02222222222220.
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [d5, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02222233222220.
.02222233222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [d6, bitmap`
................
..000000000000..
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02332222223320.
.02332222223320.
.02222222222220.
.02222222222220.
..000000000000..
................
................`],
  [s, bitmap`
................
..000000000000..
.02222222222220.
.02222222222220.
.02233222233220.
.02233222233220.
.02222222222220.
.02322222222320.
.02332222223320.
.02333333333320.
.02233333332220.
.02222333332220.
.02222222222220.
..000000000000..
................
................`]
);

setSolids([]);
let level = 0;
const levels = [
  map`
.p
..`
];

setMap(levels[level]);
setPushables({
  [player]: []
});

onInput("s", () => {

    if (!gameStarted) {
    addText("Press 's' ");
    gameStarted = true;
    return;
  }
  
  const result = Math.random() < 0.143 ? d1 : Math.random() < 0.286 ? d2 : Math.random() < 0.429 ? d3 : Math.random() < 0.571 ? d4 : Math.random() < 0.714 ? d5 : Math.random() < 0.857 ? d6 : s;
  setMap(map`${result}`);
  const playerSprite = getFirst(player);
  if (playerSprite) {
    playerSprite.y += 1;
  }
  switch (result) {
    case d1:
      addText("Jump rope");
      addText("");
      break;
    case d2:
      addText("Spin round");
      addText("");
      break;
    case d3:
      addText("Do Moonwalk");
      addText("");
      break;
    case d4:
      addText("Thumb wrestle");
      addText("");
      break;
    case d5:
      addText("Dance solo");
      addText("");
      break;
    case d6:
      addText("Yell loud");
      addText("");
      break;
    case s:
      for (let i = 1; i <= 10; i++) {
  if (i % 2 == 0) {
    addText("Do all ");
  } else {
    addText("Roll the Dice Once More:) ");
  }
}

      break;
    default:
      addText("Huh?!");
  }
});

  onInput("d", () => {
  addText("Press 's'");
  gameStarted = false;
  setMap(levels[level]);
});

